building a GtkRecentInfo can never fail.
authorEmmanuele Bassi <ebassi@gnome.org>
Mon, 25 Jun 2007 16:15:21 +0000 (16:15 +0000)
committerEmmanuele Bassi <ebassi@src.gnome.org>
Mon, 25 Jun 2007 16:15:21 +0000 (16:15 +0000)
2007-06-25  Emmanuele Bassi  <ebassi@gnome.org>

* gtk/gtkrecentmanager.c:
(build_recent_info): building a GtkRecentInfo can never fail.

(gtk_recent_manager_get_items): Clamp the list while building
it so we don't need to traverse it more than once. (#446532,
Philip Withnall)

svn path=/trunk/; revision=18228

ChangeLog
gtk/gtkrecentmanager.c

index b1f2651805aa1b7fb57199e6bb9fea7df521bddd..0d7f50e41a84e6f92b2853b5fa708a67472c9fa3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-06-25  Emmanuele Bassi  <ebassi@gnome.org>
+
+       * gtk/gtkrecentmanager.c:
+       (build_recent_info): building a GtkRecentInfo can never fail.
+
+       (gtk_recent_manager_get_items): Clamp the list while building
+       it so we don't need to traverse it more than once. (#446532,
+       Philip Withnall)
+
 2007-06-25  Tor Lillqvist  <tml@novell.com>
 
        * gdk/win32/gdkevents-win32.c (gdk_pointer_grab): Revert my
index 6f038fcd5fb94b7f32fbc3e332e886c4799427e1..d8311d4097ee13b216c7d882d8f8de2dfb880ab0 100644 (file)
@@ -1077,7 +1077,7 @@ gtk_recent_manager_has_item (GtkRecentManager *manager,
   return g_bookmark_file_has_item (priv->recent_items, uri);
 }
 
-static gboolean
+static void
 build_recent_info (GBookmarkFile  *bookmarks,
                   GtkRecentInfo  *info)
 {
@@ -1137,8 +1137,6 @@ build_recent_info (GBookmarkFile  *bookmarks,
     }
   
   g_strfreev (apps);
-  
-  return TRUE; 
 }
 
 /**
@@ -1165,7 +1163,6 @@ gtk_recent_manager_lookup_item (GtkRecentManager  *manager,
 {
   GtkRecentManagerPrivate *priv;
   GtkRecentInfo *info = NULL;
-  gboolean res;
   
   g_return_val_if_fail (GTK_IS_RECENT_MANAGER (manager), NULL);
   g_return_val_if_fail (uri != NULL, NULL);
@@ -1200,14 +1197,8 @@ gtk_recent_manager_lookup_item (GtkRecentManager  *manager,
   /* fill the RecentInfo structure with the data retrieved by our
    * parser object from the storage file 
    */
-  res = build_recent_info (priv->recent_items, info);
-  if (!res)
-    {
-      gtk_recent_info_free (info);
-      
-      return NULL;
-    }
+  build_recent_info (priv->recent_items, info);
+
   return info;
 }
 
@@ -1303,42 +1294,17 @@ gtk_recent_manager_get_items (GtkRecentManager *manager)
   for (i = 0; i < uris_len; i++)
     {
       GtkRecentInfo *info;
-      gboolean res;
+      
+      if (priv->limit != -1 && i == priv->limit)
+        break;
       
       info = gtk_recent_info_new (uris[i]);
-      res = build_recent_info (priv->recent_items, info);
-      if (!res)
-        {
-          g_warning ("Unable to create a RecentInfo object for "
-                     "item with URI `%s'",
-                     uris[i]);
-          gtk_recent_info_free (info);
-         
-          continue;
-        }
+      build_recent_info (priv->recent_items, info);
       
       retval = g_list_prepend (retval, info);
     }
   
   g_strfreev (uris);
-    
-  /* clamp the list, if a limit is present */
-  if ((priv->limit != -1) &&
-      (g_list_length (retval) > priv->limit))
-    {
-      GList *clamp, *l;
-      
-      clamp = g_list_nth (retval, priv->limit - 1);
-      
-      if (!clamp)
-        return retval;
-      
-      l = clamp->next;
-      clamp->next = NULL;
-      
-      g_list_foreach (l, (GFunc) gtk_recent_info_free, NULL);
-      g_list_free (l);
-    }
   
   return retval;
 }